package com.sale.succ.utils;

import java.io.FileOutputStream;
import java.io.PrintStream;
import java.util.Date;

public final class Logger {
	/**
	 * Logger stream.
	 */
	public static PrintStream log;

	static {
		PrintStream writer = null;
		try {
			writer = new PrintStream(new FileOutputStream(SystemConstants.LOG_FILE), true);
		} catch (Throwable e) {
			// ignoring
		}
		if (writer != null) {
			log = writer;
		} else {
			log = System.out;
		}
	}

	public static void info(String str) {
		log.println(TraderConstants.LOG_INFO + "(" + DateFormatter.dateTimeToString(new Date(), ".") + ") " + str);
	}

	public static void error(String str) {
		log.println(TraderConstants.LOG_ERROR + "(" + DateFormatter.dateTimeToString(new Date(), ".") + ") " + str);
	}

	public static void debug(String str) {
		log.println(TraderConstants.LOG_DEBUG + "(" + DateFormatter.dateTimeToString(new Date(), ".") + ") " + str);
	}

}
